package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ZhwyChart;
import com.ruoyi.service.IZhwyChartService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图表统计Controller
 * 
 * @author ruoyi
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/msr/chart")
public class ZhwyChartController extends BaseController
{
    @Autowired
    private IZhwyChartService zhwyChartService;

    /**
     * 查询图表统计列表
     */
    @PreAuthorize("@ss.hasPermi('msr:chart:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhwyChart zhwyChart)
    {
        startPage();
        List<ZhwyChart> list = zhwyChartService.selectZhwyChartList(zhwyChart);
        return getDataTable(list);
    }

    /**
     * 导出图表统计列表
     */
    @PreAuthorize("@ss.hasPermi('msr:chart:export')")
    @Log(title = "图表统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhwyChart zhwyChart)
    {
        List<ZhwyChart> list = zhwyChartService.selectZhwyChartList(zhwyChart);
        ExcelUtil<ZhwyChart> util = new ExcelUtil<ZhwyChart>(ZhwyChart.class);
        util.exportExcel(response, list, "图表统计数据");
    }

    /**
     * 获取图表统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('msr:chart:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zhwyChartService.selectZhwyChartById(id));
    }

    /**
     * 新增图表统计
     */
    @PreAuthorize("@ss.hasPermi('msr:chart:add')")
    @Log(title = "图表统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhwyChart zhwyChart)
    {
        return toAjax(zhwyChartService.insertZhwyChart(zhwyChart));
    }

    /**
     * 修改图表统计
     */
    @PreAuthorize("@ss.hasPermi('msr:chart:edit')")
    @Log(title = "图表统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhwyChart zhwyChart)
    {
        return toAjax(zhwyChartService.updateZhwyChart(zhwyChart));
    }

    /**
     * 删除图表统计
     */
    @PreAuthorize("@ss.hasPermi('msr:chart:remove')")
    @Log(title = "图表统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zhwyChartService.deleteZhwyChartByIds(ids));
    }
}
